package com.orhon.smartcampus.utils;

import com.orhon.smartcampus.auth.JwtUtils;

public class UserTypeUtil {

	
	public static Object decide(String token){
		if(token==null) {
        	return  R.NoLogin();
        }
		Long schoolId = JwtUtils.getSchoolId(token);
		if(JwtUtils.getUserType(token)!=null) {
        	if(JwtUtils.getUserType(token).equals("admin")) {
        		return " ";
        	}else if(JwtUtils.getUserType(token).equals("teacher")) {
        		return " and school_id = " + schoolId;
        	}else if(JwtUtils.getUserType(token).equals("student")) {
        		return " and school_id = " + schoolId;
        	}else if(JwtUtils.getUserType(token).equals("other")) {
        		return " and school_id = " + schoolId;
        	}else if(JwtUtils.getUserType(token).equals("parent")) {
        		return " and school_id = " + schoolId;
        	}else if(JwtUtils.getUserType(token).equals("school_admin")) {
        		return " and school_id = " + schoolId;
        	}
        }
		return " ";
    }
	
	public static Object decideId(String token){
		if(token==null) {
        	return  R.NoLogin();
        }
		Long schoolId = JwtUtils.getSchoolId(token);
		if(JwtUtils.getUserType(token)!=null) {
			if(JwtUtils.getUserType(token).equals("admin")) {
				return " ";
			}else if(JwtUtils.getUserType(token).equals("teacher")) {
        		return " and id = " + schoolId;
        	}else if(JwtUtils.getUserType(token).equals("student")) {
        		return " and id = " + schoolId;
        	}else if(JwtUtils.getUserType(token).equals("other")) {
        		return " and id = " + schoolId;
        	}else if(JwtUtils.getUserType(token).equals("parent")) {
        		return " and id = " + schoolId;
        	}else if(JwtUtils.getUserType(token).equals("school_admin")) {
        		return " and id = " + schoolId;
        	}
        }
		return " ";
    }
}
